package com.command.demo3.main;

import com.command.demo3.CeilingFan;
import com.command.demo3.RemoteControlWithUndo;
import com.command.demo3.impl.CeilingFanHighCommand;
import com.command.demo3.impl.CeilingFanLowCommand;
import com.command.demo3.impl.CeilingFanMediumCommand;
import com.command.demo3.impl.CeilingFanOffCommand;

/**
 * 支持批量撤销
 * 
 * @author Administrator
 * 
 */
public class RemoteLoader {

	public static void main(String[] args) {
		RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();

		CeilingFan ceilingFan = new CeilingFan("起居室");

		CeilingFanHighCommand ceilingFanHigh = new CeilingFanHighCommand(
				ceilingFan);
		CeilingFanMediumCommand ceilingFanMedium = new CeilingFanMediumCommand(
				ceilingFan);
		CeilingFanLowCommand ceilingFanLow = new CeilingFanLowCommand(
				ceilingFan);
		CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(
				ceilingFan);

		remoteControl.setCommand(0, ceilingFanHigh, ceilingFanOff);
		remoteControl.setCommand(1, ceilingFanMedium, ceilingFanOff);
		remoteControl.setCommand(2, ceilingFanLow, ceilingFanOff);

		remoteControl.onButtonWasPushed(0);
		remoteControl.onButtonWasPushed(1);
		remoteControl.onButtonWasPushed(2);
		remoteControl.offButtonWasPushed(2);
		System.out.println(remoteControl);
		remoteControl.undoButtonWasPushed();
		remoteControl.undoButtonWasPushed();
		remoteControl.undoButtonWasPushed();
		remoteControl.undoButtonWasPushed();
		remoteControl.undoButtonWasPushed();

	}
}
